package cn.trip.biz.controller;

import cn.itrip.beans.dto.Dto;
import cn.itrip.beans.vo.ItripLabelDicVO;
import cn.trip.biz.service.HotleRoomService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

@Controller
@RequestMapping(value = "/api/hotelroom")
public class HotelroomController {
    @Autowired
    private HotleRoomService hotleRoomService;

    @ApiOperation(value = "查询酒店房间列表", httpMethod = "POST")
    @RequestMapping(value = "/queryhotelroombyhotel", method = RequestMethod.POST, produces = "application/json")
    @ResponseBody
    public Dto queryHotelRoomByHotel(@RequestBody Map<String, Object> HotelRoomMap) {
        Dto dto = hotleRoomService.HotelRoomListMap(HotelRoomMap);
        return dto;
    }

    @ApiOperation(value = "查询酒店房间床型图片", httpMethod = "GET")
    @RequestMapping(value = "/getimg/{id}", method = RequestMethod.GET, produces = "application/json")
    @ResponseBody
    public Dto getImgByTargetId(@PathVariable String id) {
        return hotleRoomService.findimgByid(Integer.parseInt(id));
    }

    @ApiOperation(value = "查询酒店房间床型列表", httpMethod = "GET")
    @RequestMapping(value = "/queryhotelroombed", method = RequestMethod.GET, produces = "application/json")
    @ResponseBody
    public Dto queryHotelRoomBed() {
        Dto dto = null;
        try {
            List<ItripLabelDicVO> itripLabelDicList = hotleRoomService.findbedByid(new Long(1));
            dto = new Dto();
            dto.setMsg("获取成功");
            dto.setData(itripLabelDicList);
            dto.setSuccess("true");
            dto.setErrorCode("0");
        } catch (Exception e) {
            dto = new Dto();
            e.printStackTrace();
            dto.setSuccess("false");
            dto.setMsg("获取床型失败");
        }
        return dto;
    }
}

